home *** CD-ROM | disk | FTP | other *** search
- /* Copyright 2009, Boomtango.com. All Rights Reserved. */
- /* import.js
- * Responsible for importing history
- */
- Components.utils.import("resource://boomtango/app.js");
- var btimport = {
- onLoad: function(){
- this.app = boomtangoApp;
- },
- _doClose: false,
- _inImport: false,
- /*
- generateThumb: function(win){
- var canvas = document.getElementById("boomtangoThumbGen");
- return boomtangoApp.generateThumb(win, canvas);
- },
- */
- loadContent: function(url, callback){
- this.app.log("history::loadContent(" + url + ")");
- var iframe = document.getElementById("import.iframe");
- if (iframe) {
- iframe.style.height = "0px";
- iframe.webNavigation.allowAuth = false;
- iframe.webNavigation.allowImages = false;
- iframe.webNavigation.allowJavascript = false;
- iframe.webNavigation.allowMetaRedirects = true;
- iframe.webNavigation.allowPlugins = false;
- iframe.webNavigation.allowSubframes = false;
- var self = this;
- var func = function (e) {
- self.app.log("history::loadContent -Loaded(" + url + ")");
- var doc = e.originalTarget;
- if(doc.nodeName == "#document"){
- iframe.removeEventListener("DOMContentLoaded", func, true);
- window.clearTimeout(timeoutid);
- callback(doc, "");
- }
- };
- iframe.addEventListener(
- "DOMContentLoaded",
- func,
- true
- );
- var failFunc = function(){
- iframe.removeEventListener("DOMContentLoaded", func, true);
- callback(null);
- };
-
- var timeoutid = window.setTimeout(failFunc, 10*1000);
- iframe.webNavigation.loadURI(url,Components.interfaces.nsIWebNavigation,null,null,null);
- } else {
- callback(null);
- }
- },
- importfts: function(){
- boomtangoApp.tracker.importBrowserHistoryStart();
-
- this._inImport = true;
- var self = this;
- var loadFunc = function(url, callback){
- self.loadContent(url, callback);
- };
- var updateFunc = function(x, total, doContinue){
- self.app.log("import::updateFunc(" + x + " of " + total + ": " + doContinue + ")");
- document.getElementById('prog').value =
- 100 * x / total;
- if(!doContinue || self._doClose){
- window.close();
- } else {
- boomtangoApp.tracker.importBrowserHistoryDoFTS(updateFunc, loadFunc);
- }
- };
- boomtangoApp.tracker.importBrowserHistoryDoFTS(updateFunc, loadFunc);
- },
- import: function(){
- boomtangoApp.log("import::import");
- var self = this;
- boomtangoApp.tracker.importBrowserHistoryStart();
-
- var button = document.getElementById("importbutton");
- button.setAttribute("label", boomtangoApp.getString("import.importing"));
- button.setAttribute("disabled", "true");
-
- button = document.getElementById("closebutton");
- button.setAttribute("label", boomtangoApp.getString("import.close"));
-
- this._inImport = true;
- var func = function(){
- var result = boomtangoApp.tracker.importBrowserHistoryDo(
- function(x, total){
- document.getElementById('prog').value =
- 100 * x / total;
- if(self._doClose){
- return false;
- } else {
- return true;
- }
- }
- );
- if(result){
- window.setTimeout(func, 0);
- } else {
- window.close();
- }
- };
- window.setTimeout(func, 0);
- },
- close: function() {
- if(!this._inImport){
- window.close();
- } else {
- this._doClose = true;
- }
- }
- };
-